<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/pages/mastertemplate/MasterPage.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" xmlns:syn="http://www.syniverse.com">

	<ui:define name="content">
		<p:panel header="#{msg.nhapXuatKhoTitle}">

			<h:form>
				<p:fileUpload widgetVar="fileuplaod_wgt"
					fileUploadListener="#{PhieuNhapXuatBean.handleFileUpload}"
					mode="advanced" dragDropSupport="false" update=":phieuNhapXuatForm"
					sizeLimit="100000" fileLimit="1"
					allowTypes="/(\.|\/)(#{DataConfigBean.fileExtensionPattern})$/" />
			</h:form>

			<h:form>
				<p:commandButton style="width:150px;float: left;margin-top:10px;"
					value="#{msg.Button_export}"
					actionListener="#{PhieuNhapXuatBean.downloadFileCSV}" ajax="false">
					<p:fileDownload value="#{PhieuNhapXuatBean.file}" />
				</p:commandButton>
			</h:form>

			<h:form id="phieuNhapXuatForm">
				<p:growl id="phieuNhapXuatFormMessage" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />

				<p:dataTable id="dataTable" var="phieuNhapXuat"
					value="#{PhieuNhapXuatBean.listPhieuNhapXuat}" paginator="true"
					rows="10"
					filteredValue="#{PhieuNhapXuatBean.filteredPhieuNhapXuat}"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,20,50,100" widgetVar="dataTableForm"
					style="width: 100%; margin: 45px auto;">


					<f:facet name="header">
						<h:outputText value="#{msg.nhanhSachNhapXuatKho}"
							styleClass="tableHeader" />
						<div style="margin: -4px -11px 5px; float: right;">
							<p:commandButton style="height: 25px"
								update=":addPhieuNhapXuatForm:display" value="+ thêm mới"
								rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
								actionListener="#{PhieuNhapXuatBean.notifyAdd}"
								onclick="PF('phieuNhapXuatDialog').show();">
							</p:commandButton>
						</div>

					</f:facet>

					<p:column headerText="#{msg.soChungTu}"
						filterBy="#{phieuNhapXuat.soChungTu}" filterMatchMode="contains"
						sortBy="#{phieu.soChungTu}">#{phieuNhapXuat.soChungTu}  </p:column>

					<p:column headerText="#{msg.tenKhoHang}"
						filterBy="#{phieuNhapXuat.khoHang}" filterMatchMode="contains">#{phieuNhapXuat.khoHang}  </p:column>

					<p:column headerText="#{msg.donHang}"
						filterBy="#{phieuNhapXuat.donHang}" filterMatchMode="contains">#{phieuNhapXuat.donHang}  </p:column>

					<p:column headerText="#{msg.ngayLap}"
						filterBy="#{phieuNhapXuat.ngayLap}" filterMatchMode="contains">#{phieuNhapXuat.ngayLap}  </p:column>

					<p:column headerText="#{msg.nguoiLap}"
						filterBy="#{phieuNhapXuat.nguoiLap}" filterMatchMode="contains">#{phieuNhapXuat.nguoiLap}  </p:column>

					<p:column headerText="#{msg.loaiPhieu}"
						filterBy="#{phieuNhapXuat.loaiPhieu}" filterMatchMode="contains">#{phieuNhapXuat.loaiPhieu}  </p:column>

					<p:column headerText="#{msg.soTaiKhoanCo}"
						filterBy="#{phieuNhapXuat.soTaiKhoanCo}"
						filterMatchMode="contains">  #{phieuNhapXuat.soTaiKhoanCo}   </p:column>

					<p:column headerText="#{msg.soTaiKhoanNo}"
						filterBy="#{phieuNhapXuat.loaiPhieu}" filterMatchMode="contains">  #{phieuNhapXuat.soTaiKhoanNo}   </p:column>

					<p:column headerText="#{msg.coHoaDon}"
						filterBy="#{phieuNhapXuat.coHoaDon}" filterMatchMode="contains">  #{phieuNhapXuat.coHoaDon}   </p:column>

					<p:column headerText="#{msg.table_actions}"
						style="text-align:center;min-width:10px">

						<p:commandButton styleClass="smallButton"
							icon="ui-icon ui-icon-search"
							update=":addPhieuNhapXuatForm:display :addChiTietPhieuNhapXuatForm:displayChiTietPhieuNhapXuat"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							actionListener="#{PhieuNhapXuatBean.notifyEdit(phieuNhapXuat)}"
							oncomplete="PF('phieuNhapXuatDialog').show();">

						</p:commandButton>
						<p:commandButton style="margin-left: 5px" styleClass="smallButton"
							icon="ui-icon ui-icon-trash"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							oncomplete="PF('confirmRemove').show();">
							<f:setPropertyActionListener value="#{phieuNhapXuat}"
								target="#{PhieuNhapXuatBean.selectedPhieuNhapXuat}" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

			</h:form>

			<h:form id="addPhieuNhapXuatForm">
				<p:growl id="addPhieuNhapXuatFormMessage" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />
				<p:dialog id="dialog" header="Thêm mới/ Sửa" modal="true"
					widgetVar="phieuNhapXuatDialog" resizable="false">

					<p:scrollPanel id="display" mode="native"
						style="width:800px;height:500px">

						<h:panelGrid columns="2" id="infoForm">
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px"
									value="#{msg.loaiPhieu}" />
								<p:selectOneMenu styleClass="inputText"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.loaiPhieu}"
									filter="true" filterMatchMode="contains" required="true">
									<f:selectItem itemLabel="Select One" itemValue=""></f:selectItem>
									<f:selectItems value="#{PhieuNhapXuatBean.listLoaiPhieu}"
										var="selectItem" itemLabel="#{selectItem}"
										itemValue="#{selectItem}" />
									<p:ajax event="change" update=":addPhieuNhapXuatForm:display"
										listener="#{PhieuNhapXuatBean.changeLoaiPhieu}"></p:ajax>
								</p:selectOneMenu>
							</h:panelGrid>

							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" for="soChungTu"
									value="#{msg.soChungTu}" />
								<p:inputText styleClass="inputText" id="soChungTu"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.soChungTu}"
									readonly="true" disabled="#{PhieuNhapXuatBean.edit}">
								</p:inputText>
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" value="#{msg.ngayLap}" />
								<p:calendar style="min-width:140px"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.ngayLap}"
									pattern="#{DataConfigBean.datepattern}" showButtonPanel="true">
									<syn:convertTimestamp pattern="#{DataConfigBean.datepattern}" />
								</p:calendar>
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" value="#{msg.khoHang}" />
								<p:selectOneMenu styleClass="inputText"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.khoHang}"
									filter="true" filterMatchMode="contains">
									<f:selectItems value="#{KhoHangBean.listKhoHang}"
										var="selectItem" itemLabel="#{selectItem.tenKhoHang}"
										itemValue="#{selectItem.maKhoHang}" />
								</p:selectOneMenu>
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" value="#{msg.donHang}" />
								<p:selectOneMenu styleClass="inputText"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.donHang}"
									filter="true" filterMatchMode="contains" required="true"
									requiredMessage="Yêu cầu chọn đơn hàng">
									<f:selectItem itemLabel="Select One" itemValue=""></f:selectItem>
									<f:selectItems value="#{PhieuNhapXuatBean.listDH}"
										var="selectItem" itemLabel="#{selectItem.soChungTu}"
										itemValue="#{selectItem.soChungTu}" />
									<p:ajax event="change" update=":addPhieuNhapXuatForm:display"
										listener="#{PhieuNhapXuatBean.updateVatTuHangHoa}"></p:ajax>
								</p:selectOneMenu>
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" value="#{msg.nguoiLap}" />
								<p:selectOneMenu styleClass="inputText"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.nguoiLap}"
									filter="true" filterMatchMode="contains">
									<f:selectItems value="#{NhanVienBean.listNhanVien}"
										var="selectItem" itemLabel="#{selectItem.maNhanVien}"
										itemValue="#{selectItem.maNhanVien}" />
								</p:selectOneMenu>
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px"
									value="#{msg.soTaiKhoanCo}" />
								<p:inputText styleClass="inputText" id="soTaiKhoanCo"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.soTaiKhoanCo}">
								</p:inputText>
							</h:panelGrid>

							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px"
									value="#{msg.soTaiKhoanNo}" />
								<p:inputText styleClass="inputText" id="soTaiKhoanNo"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.soTaiKhoanNo}">
								</p:inputText>
							</h:panelGrid>

							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" value="#{msg.coHoaDon}" />
								<p:selectOneRadio id="options"
									disabled="#{PhieuNhapXuatBean.edit}"
									value="#{PhieuNhapXuatBean.phieuNhapXuat.coHoaDon}">
									<f:selectItem itemLabel="Có" itemValue="true" />
									<f:selectItem itemLabel="Khong" itemValue="false" />
								</p:selectOneRadio>
							</h:panelGrid>
						</h:panelGrid>

						<p:scrollPanel id="display" mode="native" style="width:800px;">

							<h:panelGrid columns="2" id="infoForm"
								title="#{msg.thongTinDonHang}">
								<h:panelGrid columns="2">
									<p:outputLabel style="margin-left: 20px"
										value="#{msg.loaiDonHang}" />
									<p:outputLabel
										value="#{PhieuNhapXuatBean.donHangSelected.loaiDonHang}" />
								</h:panelGrid>
								<h:panelGrid columns="2">
									<p:outputLabel style="margin-left: 20px" for="soChungTu"
										value="#{msg.soChungTu}" />
									<p:outputLabel
										value="#{PhieuNhapXuatBean.donHangSelected.soChungTu}">
									</p:outputLabel>
								</h:panelGrid>

								<h:panelGrid columns="2">
									<p:outputLabel style="margin-left: 20px" value="#{msg.ngayLap}" />
									<p:outputLabel
										value="#{PhieuNhapXuatBean.donHangSelected.ngayLap}">
										<syn:convertTimestamp pattern="#{DataConfigBean.datepattern}" />
									</p:outputLabel>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='MUA_HANG' or DonHangBean.loaiDonHang=='BAN_HANG' }">
									<p:outputLabel style="margin-left: 20px"
										value="#{msg.phuongTienVanChuyen}" />
									<p:selectOneMenu styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.phuongTienVanChuyen}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value="#{DonHangBean.listPhuongTienVanChuyen}"
											var="selectItem" itemLabel="#{selectItem}"
											itemValue="#{selectItem}" />
									</p:selectOneMenu>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='MUA_HANG' or DonHangBean.loaiDonHang=='BAN_HANG' }">
									<p:outputLabel style="margin-left: 20px"
										value="#{msg.nguoiGiaoHang}" />
									<p:inputText styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.nguoiGiaoHang}">
									</p:inputText>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='MUA_HANG' or DonHangBean.loaiDonHang=='BAN_HANG' }">
									<p:outputLabel style="margin-left: 20px"
										value="#{msg.soDTNguoiGiaoHang}" />
									<p:inputText styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.soDTNguoiGiaoHang}">
									</p:inputText>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='MUA_HANG' or DonHangBean.loaiDonHang=='BAN_HANG' }">
									<p:outputLabel style="margin-left: 20px" value="#{msg.congTy}" />
									<p:selectOneMenu styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.doiTac}" filter="true"
										filterMatchMode="contains">
										<f:selectItem itemLabel="Select One" itemValue=""></f:selectItem>
										<f:selectItems value="#{DoiTacBean.listDoiTac}"
											var="selectItem" itemLabel="#{selectItem.tenDoiTac}"
											itemValue="#{selectItem.maDoiTac}" />
									</p:selectOneMenu>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='BAN_HANG'}">
									<p:outputLabel style="margin-left: 20px" for="caNhan"
										value="#{msg.caNhan}" />
									<p:inputText styleClass="inputText" id="caNhan"
										value="#{PhieuNhapXuatBean.donHangSelected.caNhan}">
									</p:inputText>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='DUNG_NOI_BO'}">
									<p:outputLabel style="margin-left: 20px"
										value="#{msg.nhanVienNhan}" />
									<p:selectOneMenu styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.nhanVienNhan}" filter="true"
										filterMatchMode="contains">
										<f:selectItem itemLabel="" itemValue="" />
										<f:selectItems value="#{NhanVienBean.listNhanVien}"
											var="selectItem" itemLabel="#{selectItem.hoTen}"
											itemValue="#{selectItem.maNhanVien}" />
									</p:selectOneMenu>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='CHUYEN_KHO'}">


									<p:outputLabel style="margin-left: 20px"
										value="#{msg.khoNhanHang}" />
									<p:selectOneMenu styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.khoNhanHang}" filter="true"
										filterMatchMode="contains">
										<f:selectItem itemLabel="" itemValue="" />
										<f:selectItems value="#{KhoHangBean.listKhoHang}"
											var="selectItem" itemLabel="#{selectItem.tenKhoHang}"
											itemValue="#{selectItem.maKhoHang}" />
									</p:selectOneMenu>
								</h:panelGrid>
								<h:panelGrid columns="2"
									rendered="#{DonHangBean.loaiDonHang=='CHUYEN_KHO'}">
									<p:outputLabel style="margin-left: 20px"
										value="#{msg.khoXuatHang}" />
									<p:selectOneMenu styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.khoXuatHang}" filter="true"
										filterMatchMode="contains">
										<f:selectItem itemLabel="" itemValue="" />
										<f:selectItems value="#{KhoHangBean.listKhoHang}"
											var="selectItem" itemLabel="#{selectItem.tenKhoHang}"
											itemValue="#{selectItem.maKhoHang}" />
									</p:selectOneMenu>
								</h:panelGrid>

								<h:panelGrid columns="2">
									<p:outputLabel style="margin-left: 20px"
										value="#{msg.trangThai}" />

									<p:selectOneMenu styleClass="inputText"
										value="#{PhieuNhapXuatBean.donHangSelected.trangThai}" filter="true"
										filterMatchMode="contains">
										<f:selectItems value="#{DonHangBean.listTrangThai}"
											var="selectItem" itemLabel="#{selectItem}"
											itemValue="#{selectItem}" />
									</p:selectOneMenu>
								</h:panelGrid>
							</h:panelGrid>

							<p:dataTable id="dataTableChiTietDonHang" var="chiTietDonHang"
								value="#{DonHangBean.listPODetail}" lazy="true" paginator="true"
								rows="10"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="10,20,50,100" style="width: 100%;"
								editable="true">

								<f:facet name="header">
									<h:outputText value="#{msg.danhSachChiTietDonHang}"
										styleClass="tableHeader" />
									<div style="margin: -4px -11px 5px; float: right;">
										<p:commandButton style="height: 25px" value="+ thêm mới"
											rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
											update=":addChiTietDonHangForm:displayChiTietDonHang"
											actionListener="#{DonHangBean.notifyAddChiTietDonHang}"
											onclick="PF('chiTietDonHangDialog').show();">
										</p:commandButton>
									</div>

								</f:facet>

								<p:column headerText="#{msg.soChungTu}">#{chiTietDonHang.donHang} 
											</p:column>

								<p:column headerText="#{msg.maVatTu}">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{chiTietDonHang.vatTuHangHoa}" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{chiTietDonHang.vatTuHangHoa}" />
										</f:facet>
									</p:cellEditor>
								</p:column>

								<p:column headerText="#{msg.tenVatTu}">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{chiTietDonHang.tenVTHH}" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{chiTietDonHang.tenVTHH}" />
										</f:facet>
									</p:cellEditor>
								</p:column>


								<p:column headerText="#{msg.soLuong}">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{chiTietDonHang.soLuong}" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{chiTietDonHang.soLuong}" />
										</f:facet>
									</p:cellEditor>
								</p:column>

								<p:column headerText="#{msg.donGia}">
									<p:cellEditor>
										<f:facet name="output">
											<h:outputText value="#{chiTietDonHang.donGia}" />
										</f:facet>
										<f:facet name="input">
											<p:inputText value="#{chiTietDonHang.donGia}" />
										</f:facet>
									</p:cellEditor>
								</p:column>

								<p:column>

									<p:commandButton style="margin-left: 5px"
										styleClass="smallButton" icon="ui-icon ui-icon-trash"
										rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
										oncomplete="PF('confirmRemoveChiTietDonHang').show();">
										<f:setPropertyActionListener value="#{chiTietDonHang}"
											target="#{DonHangBean.selectedProductOrderDetail}" />
									</p:commandButton>

								</p:column>
							</p:dataTable>

							<p:commandButton value="Lưu" actionListener="#{DonHangBean.save}"
								update=":donHangForm :addDonHangForm:display" process=""
								oncomplete="if(args.opSuccess) {PF('donHangDialog').hide(); PF('DonHangTable').filter()}">

							</p:commandButton>

						</p:scrollPanel>



						<p:dataTable id="dataTableChiTietPhieuNhapXuat"
							var="chiTietPhieuNhapXuat"
							value="#{PhieuNhapXuatBean.listChiTietNhapXuat}" lazy="true"
							paginator="true" rows="10"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							rowsPerPageTemplate="10,20,50,100"
							style="width: 100%; margin: 45px auto;">

							<f:facet name="header">
								<h:outputText value="#{msg.danhSachChiTietPhieuNhapXuat}"
									styleClass="tableHeader" />
								<div style="margin: -4px -11px 5px; float: right;">
									<p:commandButton style="height: 25px"
										update=":addChiTietPhieuNhapXuatForm:displayChiTietPhieuNhapXuat :addPhieuNhapXuatForm:addPhieuNhapXuatFormMessage"
										value="+ thêm mới"
										rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
										actionListener="#{PhieuNhapXuatBean.notifyAddChiTietPhieuNhapXuat}"
										oncomplete="if(args.opSuccess) PF('ChiTietPhieuNhapXuatDialog').show();">
									</p:commandButton>
								</div>

							</f:facet>

							<p:column headerText="#{msg.maVatTu}"
								filterBy="#{chiTietPhieuNhapXuat.vatTuHangHoa.maVTHH}"
								filterMatchMode="contains"
								sortBy="#{chiTietPhieuNhapXuat.vatTuHangHoa.maVTHH}">#{chiTietPhieuNhapXuat.maVthh} 
											</p:column>

							<p:column headerText="#{msg.tenVatTu}"
								filterBy="#{chiTietPhieuNhapXuat.vatTuHangHoa.tenVTHH}"
								filterMatchMode="contains"
								sortBy="#{chiTietPhieuNhapXuat.vatTuHangHoa.tenVTHH}">#{chiTietPhieuNhapXuat.tenVTHH} 
											</p:column>

							<p:column headerText="#{msg.serialNumber}"
								filterBy="#{chiTietPhieuNhapXuat.serialNumber}"
								filterMatchMode="contains"
								sortBy="#{chiTietPhieuNhapXuat.serialNumber}">#{chiTietPhieuNhapXuat.serialNumber} 
											</p:column>

							<p:column headerText="#{msg.productName}"
								filterBy="#{chiTietPhieuNhapXuat.productName}"
								filterMatchMode="contains"
								sortBy="#{chiTietPhieuNhapXuat.productName}">#{chiTietPhieuNhapXuat.productName} 
											</p:column>

							<p:column headerText="#{msg.soLuong}">#{chiTietPhieuNhapXuat.soLuong} 
											</p:column>


							<p:column headerText="#{msg.table_actions}"
								style="text-align:center;min-width:10px">

								<p:commandButton style="margin-left: 5px"
									disabled="#{PhieuNhapXuatBean.edit}" styleClass="smallButton"
									icon="ui-icon ui-icon-trash"
									rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
									oncomplete="PF('confirmRemoveChiTietNhapXuat').show();">
									<f:setPropertyActionListener value="#{chiTietPhieuNhapXuat}"
										target="#{PhieuNhapXuatBean.selectedChiTietPhieuNhapXuat}" />
								</p:commandButton>
							</p:column>



						</p:dataTable>

						<p:commandButton value="Lưu" disabled="#{PhieuNhapXuatBean.edit}"
							actionListener="#{PhieuNhapXuatBean.save}"
							update=":phieuNhapXuatForm :addPhieuNhapXuatForm:display"
							oncomplete="if(args.opSuccess){ PF('phieuNhapXuatDialog').hide() ;PF('dataTableForm').filter()}">
						</p:commandButton>

					</p:scrollPanel>

				</p:dialog>

			</h:form>

			<h:form>
				<p:dialog id="confirmRemove" header="Xác nhận" modal="true"
					widgetVar="confirmRemove">

					<h:outputText style="margin-left: 20px" value="Bạn có chắc không ?" />
					<p:commandButton value="Đồng ý" update=":phieuNhapXuatForm"
						actionListener="#{PhieuNhapXuatBean.removePhieuNhapXuat}"
						oncomplete="PF('confirmRemove').hide() ; PF('dataTableForm').filter()"></p:commandButton>
					<p:commandButton value="Hủy"></p:commandButton>

				</p:dialog>
			</h:form>

			<h:form>
				<p:dialog id="removeCtnxDialog" header="Xác nhận" modal="true"
					widgetVar="confirmRemoveChiTietNhapXuat">

					<h:outputText style="margin-left: 20px" value="Bạn có chắc không ?" />
					<p:commandButton value="Đồng ý"
						update=":addPhieuNhapXuatForm:display"
						actionListener="#{PhieuNhapXuatBean.removeChiTietPhieuNhapXuat}"
						oncomplete="PF('confirmRemoveChiTietNhapXuat').hide()"></p:commandButton>
					<p:commandButton value="Hủy"></p:commandButton>

				</p:dialog>
			</h:form>


			<h:form id="addChiTietPhieuNhapXuatForm">
				<p:growl id="addChiTietPhieuNhapXuatFormMessage" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />
				<p:dialog id="dialogChiTietPhieuNhapXuat" header="Thêm mới/ Sửa"
					modal="true" widgetVar="ChiTietPhieuNhapXuatDialog"
					resizable="false" style="width:800px;height:500px">

					<p:panel id="displayChiTietPhieuNhapXuat">
						<h:panelGrid columns="1">
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" for="maVatTu"
									value="#{msg.maVatTu}" />
								<p:selectOneMenu styleClass="inputText" required="true"
									requiredMessage="#{msg.maVatTu}: #{msg.valuerequired}"
									id="maVatTu" value="#{PhieuNhapXuatBean.maVthh}" filter="true"
									filterMatchMode="contains">
									<f:selectItem itemLabel="Select One" itemValue=""></f:selectItem>
									<f:selectItems value="#{PhieuNhapXuatBean.listVatTuHangHoa}"
										var="selectItem" itemLabel="#{selectItem.tenVTHH}"
										itemValue="#{selectItem.maVTHH}" />

									<p:ajax event="change"
										update=":addChiTietPhieuNhapXuatForm:displayChiTietPhieuNhapXuat"
										listener="#{PhieuNhapXuatBean.changeVatTuHangHoa}"></p:ajax>

								</p:selectOneMenu>

								<p:outputLabel style="margin-left: 20px" for="maVatTu"
									value="#{msg.TongTonKho} : #{PhieuNhapXuatBean.tongTonKho}"
									rendered="#{PhieuNhapXuatBean.xuatHang}" />

							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" for="serialNumber"
									value="#{msg.serialNumber}"
									rendered="#{PhieuNhapXuatBean.nhapHang}" />
								<p:inputText styleClass="inputText" required="false"
									requiredMessage="#{msg.serialNumber}: #{msg.valuerequired}"
									id="serialNumber" value="#{PhieuNhapXuatBean.serialNumber}"
									rendered="#{PhieuNhapXuatBean.nhapHang}"
									disabled="#{PhieuNhapXuatBean.tinhchatVTHH != 'VTHH_CO_SERIAL'}">
								</p:inputText>
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" for="productName"
									value="#{msg.productName}"
									rendered="#{PhieuNhapXuatBean.nhapHang}" />
								<p:inputText styleClass="inputText" required="false"
									requiredMessage="#{msg.productName}: #{msg.valuerequired}"
									id="productName" value="#{PhieuNhapXuatBean.productName}"
									rendered="#{PhieuNhapXuatBean.nhapHang}"
									disabled="#{PhieuNhapXuatBean.tinhchatVTHH != 'VTHH_CO_SERIAL'}">
								</p:inputText>
							</h:panelGrid>

							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" for="soLuongForNhapKho"
									value="#{msg.soluong}" rendered="#{PhieuNhapXuatBean.nhapHang}" />
								<p:inputText styleClass="inputText" required="false"
									requiredMessage="#{msg.soluong}: #{msg.valuerequired}"
									id="soLuongForNhapKho"
									value="#{PhieuNhapXuatBean.soLuongForNhapKho}"
									rendered="#{PhieuNhapXuatBean.nhapHang}"
									disabled="#{PhieuNhapXuatBean.tinhchatVTHH != 'VTHH_KHONG_SERIAL'}">
								</p:inputText>
							</h:panelGrid>

							<h:panelGrid columns="2">
								<p:outputLabel style="margin-left: 20px" for="soLuongForXuatKho"
									value="#{msg.soluong}" rendered="#{PhieuNhapXuatBean.xuatHang}" />
								<p:inputText styleClass="inputText" required="false"
									requiredMessage="#{msg.soluong}: #{msg.valuerequired}"
									id="soLuongForXuatKho"
									value="#{PhieuNhapXuatBean.soLuongForXuatKho}"
									rendered="#{PhieuNhapXuatBean.xuatHang}"
									disabled="#{PhieuNhapXuatBean.tinhchatVTHH != 'VTHH_KHONG_SERIAL'}">
								</p:inputText>
							</h:panelGrid>


							<h:panelGrid columns="1" rendered="#{PhieuNhapXuatBean.xuatHang}">

								<p:scrollPanel style="width:800px;height:300px"
									rendered="#{PhieuNhapXuatBean.tinhchatVTHH != 'VTHH_KHONG_SERIAL'}">
									<p:dataTable id="dataTable"
										selection="#{PhieuNhapXuatBean.selectedTonKhos}"
										rowKey="#{ton.serialNumber}" var="ton"
										value="#{PhieuNhapXuatBean.listTonKho}" paginator="true"
										rows="10"
										paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
										rowsPerPageTemplate="10,20,50,100"
										style="width: 100%; margin: 45px auto;">

										<f:facet name="header">
											<h:outputText value="#{msg.danhSachTonKho}"
												styleClass="tableHeader" />
										</f:facet>

										<p:column selectionMode="multiple"
											style="width:10%;text-align:center" />

										<p:column headerText="#{msg.maVatTuHangHoa}"
											filterBy="#{ton.vatTuHangHoa}" filterMatchMode="contains"
											sortBy="#{ton.vatTuHangHoa}">#{ton.vatTuHangHoa}  </p:column>


										<p:column headerText="#{msg.serialNumber}"
											filterBy="#{ton.serialNumber}" filterMatchMode="contains"
											sortBy="#{ton.serialNumber}">#{ton.serialNumber}  </p:column>

										<p:column headerText="#{msg.productName}"
											filterBy="#{ton.productName}" filterMatchMode="contains"
											sortBy="#{ton.productName}">#{ton.productName}  </p:column>



									</p:dataTable>
								</p:scrollPanel>
							</h:panelGrid>

							<h:panelGrid columns="2">
								<p:commandButton value="Lưu"
									actionListener="#{PhieuNhapXuatBean.addChiTietPhieuNhapXuat}"
									update=" :addChiTietPhieuNhapXuatForm:displayChiTietPhieuNhapXuat :addPhieuNhapXuatForm:display :addChiTietPhieuNhapXuatForm:addChiTietPhieuNhapXuatFormMessage"
									oncomplete="if(args.opSuccess) PF('ChiTietPhieuNhapXuatDialog').hide()">
								</p:commandButton>
							</h:panelGrid>
						</h:panelGrid>

					</p:panel>
				</p:dialog>
			</h:form>

		</p:panel>

	</ui:define>
</ui:composition>
